//
//  ImageUpLabel.m
//  Products_B
//
//  Created by lanou on 16/5/29.
//  Copyright © 2016年 朋学友. All rights reserved.
//

#import "ImageUpLabel.h"


@implementation ImageUpLabel


-(instancetype)initWithFrame:(CGRect )frame image:(UIImage *)image textLabel:
(NSString *)textString tapAction:(TapBlock)tapBlock{
    CGRect newFrame = frame;
    newFrame.size.height = newFrame.size.height;
    if (self = [super initWithFrame:newFrame]) {
        self.tapBlock = tapBlock;
        self.LeftimageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, newFrame.size.height, newFrame.size.height)];
        if (image) {
            _LeftimageView.image = image;
        }
        [self addSubview:_LeftimageView];
        
        _textlabel = [[UILabel alloc] initWithFrame:CGRectMake(newFrame.size.height + 10, 0, newFrame.size.width - newFrame.size.height, newFrame.size.height)];
        if (textString) {
            _textlabel.text = textString;
        }
        _textlabel.textAlignment = NSTextAlignmentLeft;
        _textlabel.font = [UIFont systemFontOfSize:14];
        [self addSubview:_textlabel];
        
        UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapAction:)];
        [self addGestureRecognizer:tap];
    }
    return self;
    
    
}

-(void)tapAction:(UITapGestureRecognizer *)tap{

    if (self.tapBlock) {
        self.tapBlock(0);
    }
}

-(void)setTextlabelText:(NSString *)text{

    self.textlabel.text = text;

}



@end
